package com.longdaji.decoration.di.module;

import android.app.Application;
import android.content.Context;

import com.longdaji.decoration.data.DataManager;
import com.longdaji.decoration.data.db.DBHelper;
import com.longdaji.decoration.data.db.DBHelperImp;
import com.longdaji.decoration.data.network.HttpHelper;
import com.longdaji.decoration.data.network.HttpHelperImp;
import com.longdaji.decoration.data.prefs.PrefsHelper;
import com.longdaji.decoration.data.prefs.PrefsHelperImp;

import javax.inject.Singleton;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * Created by longtao on 2017/12/26.
 */

@Module
public abstract class ApplicationModule {
    //expose Application as an injectable context
    @Binds
    abstract Context provideAppContext(Application application);

    @Provides
    @Singleton
    static HttpHelper provideHttpHelper(HttpHelperImp retrofitHelper) {
        return retrofitHelper;
    }

    @Provides
    @Singleton
    static DBHelper provideDBHelper(DBHelperImp dbHelper) {
        return dbHelper;
    }

    @Provides
    @Singleton
    static PrefsHelper providePreferencesHelper(PrefsHelperImp prefsHelperImp) {
        return prefsHelperImp;
    }

    @Provides
    @Singleton
    static DataManager provideDataManager(HttpHelper httpHelper, DBHelper DBHelper, PrefsHelper prefsHelper) {
        return new DataManager(httpHelper, DBHelper, prefsHelper);
    }
}
